﻿using System;
using System.Collections.Generic;
using System.Text;
using TTEngine;

namespace TTEditor.Resource
{
    public interface IAssetViewer
    {
        UInt32 AssetTypeID
        {
            get;
        }
        void OnGUI(IAsset asset);
    }
    public class ViewerMgr
    {
        static Dictionary<UInt32, IAssetViewer> viewers = new Dictionary<uint, IAssetViewer>();

        public static void RegViewer(IAssetViewer viewer)
        {
            if (viewers.ContainsKey(viewer.AssetTypeID))
                throw new Exception("already have this viewer.");
            viewers[viewer.AssetTypeID] = viewer;
        }
        public static void OnGUI(IAsset asset)
        {
            if(viewers.ContainsKey(asset.AssetTypeID)==false)
            {
                return;
            }
            viewers[asset.AssetTypeID].OnGUI(asset);
        }
    }
}
